package com.yunsuo.access;

import com.yunsuo.CallableThreadTest;
import com.yunsuo.bean.HttpConnection;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class AccessServer {
    public static void access(){
        final HttpConnection httpConnection=new HttpConnection();
        //System.out.println("begin");

        Runnable runnable = new Runnable() {
            public void run() {
                //System.out.println("心跳："+Thread.currentThread().getName());
                //System.out.println("心跳================心跳");
                CallableThreadTest.request();//树莓派向服务器发送请求
            }
        };

        ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
        // 第二个参数为首次执行的延时时间，第三个参数为定时执行的间隔时间
        service.scheduleAtFixedRate(runnable, 3, 2, TimeUnit.SECONDS);

        //System.out.println("end");
    }

}
